home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 1999 June / maximum-cd-1999-06.iso / Fireworks 2 / data1.cab / Program_Files / Settings / HTML_Code / FrontPage / Imagemap.htt next >
Encoding:
Text File  |  1999-03-01  |  10.9 KB  |  334 lines

  1. // Fireworks Micfrosoft FrontPage HTML & javascript for single images & imagemaps.
  2. // Version 2.0 28JAN99
  3.  
  4. // To export HTML without comments change the value of variable doComments to "false".
  5. var doComments=true;
  6.  
  7. // When doComments is set to "true" the WRITE_HTML_COMMENT and WRITE_JS_COMMENT functions
  8. // include HTML and JavaScript in the exported file.
  9. function WRITE_HTML_COMMENT(str) {
  10.     if (doComments) WRITE_HTML("<!--"+str+"-->\n");
  11. }
  12.  
  13. function WRITE_JS_COMMENT(str) {
  14.     if (doComments) WRITE_HTML("/* "+str+" */\n");
  15. }
  16.  
  17. WRITE_HTML("\n");
  18. WRITE_HTML("<html>\n");
  19. WRITE_HTML("\n");
  20.  
  21. WRITE_HTML("<head>\n");
  22. WRITE_HTML("\n");
  23.  
  24. // Use Base Name from export dialog as document title.
  25. WRITE_HTML("<title>", exportDoc.filename, "</title>\n");
  26. WRITE_HTML("\n");
  27.  
  28. // Write Meta tags.
  29. WRITE_HTML("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=");
  30. var charSet = App.getPref("HtmlCharSet");
  31. if (charSet == "") charSet = "iso-8859-1";
  32. WRITE_HTML(charSet + "\">\n"); 
  33. WRITE_HTML("<meta name=\"description\" content=\"Fireworks Image Map\">\n");
  34. WRITE_HTML("\n");
  35.  
  36. // Write HTML target and date created.
  37. var d = new Date();
  38. WRITE_HTML("<!-- Fireworks 2.0  FrontPage target.  \n    Created ", d, " -->\n");
  39. WRITE_HTML("\n");
  40.  
  41. // Close head tag.
  42. WRITE_HTML("</head>\n");
  43. WRITE_HTML("\n");
  44.  
  45. // Begin body tag. Set background color to Fireworks document canvas color.
  46. WRITE_HTML("<body bgcolor=\"#", exportDoc.backgroundColor, "\">\n");
  47. WRITE_HTML("\n");
  48.  
  49. // Copying and pasting from the Fireworks-generated HTML file into an existing FrontPage 
  50. // document while in Normal view can cause a loss of functionality. To help the user avoid this,
  51. // write this instructional text to display at the top of the document when viewed in FrontPage or in a browser.
  52. WRITE_HTML("<p>To place this Fireworks output in an existing HTML page, switch to the "); 
  53. WRITE_HTML("HTML view and copy the HTML and JavaScript code beginning with the line:</p>\n");
  54. WRITE_HTML("<p>[!------------ BEGIN COPYING HERE ---------------]</p>\n");
  55. WRITE_HTML("<p>and continuing to the line:</p>\n");
  56. WRITE_HTML("<p>[!------------ STOP COPYING HERE ---------------]</p>\n");
  57. WRITE_HTML("<p>Paste the code into the body of your destination document in the HTML view.</p>\n");
  58. WRITE_HTML("<p>Note: This document and the destination document must be in the same folder.</p>\n");
  59. WRITE_HTML("<p> If you do not want to place this Fireworks output in an existing HTML page, delete this text.</p>\n");
  60. WRITE_HTML("\n");
  61.  
  62. // Write comment for start of image map copy/paste section.
  63. WRITE_HTML_COMMENT("-- Copy the image and map code, and paste the data where ")
  64. WRITE_HTML_COMMENT("you want the image to appear in the destination document. --")
  65. WRITE_HTML("\n");
  66. WRITE_HTML_COMMENT("-------------------------- BEGIN COPYING HERE --------------------------")
  67. WRITE_HTML("\n");
  68.  
  69. // Declare variables for processing Behaviors.
  70. var hasImagemap = false;
  71. var hasStatusMessages = false;
  72.  
  73. var kActionStatusMessage = 1;
  74. var kActionSwapImage = 2;
  75. var kActionRadioGroup = 3;
  76.  
  77. var kEventMouseOver = 0;
  78. var kEventOnClick = 1;
  79. var kEventMouseOut = 2;
  80.  
  81. // Write a client-side imagemap
  82. if (exportDoc.clientMap) { 
  83.     var i = 0;
  84.     while (i < imagemap.numberOfURLs) {
  85.         hasImagemap = true; // at least 1 url in the imagemap.
  86.         for (var j=0; j<imagemap[i].behaviors.numberOfBehaviors; j++) {
  87.             var curBehavior = imagemap[i].behaviors[j];
  88.             if (curBehavior.action == kActionStatusMessage) {
  89.                 hasStatusMessages = true;
  90.             }
  91.         }
  92.         i++;
  93.     }
  94.     if (exportDoc.hasBackgroundLink) {
  95.         hasImagemap = true;
  96.     }
  97. }
  98.  
  99. /* Note: In simple imagemaps using the template Imagemap.htt, the only available 
  100.    behavior is the status bar message. Otherwise, the Slices.htt template is used. */
  101. function ProcessBehavior(theCurBehaviors) {
  102.     var gotJavascript = false;
  103.     var overStat = false;
  104.     var hitStat = false;
  105.     var outStat = false;
  106.     var eraseStatOnRestore = false;
  107.     for (var i=0; i<theCurBehaviors.numberOfBehaviors; i++) {
  108.         var curBehavior = theCurBehaviors[i];
  109.         var curJavascript = "";
  110.         var gotStat = false;
  111.         if (curBehavior.action == kActionStatusMessage) {
  112.             gotJavascript = true;
  113.             gotStat = true;
  114.             var statMsg = curBehavior.statusText;
  115.             var restore = curBehavior.restoreOnMouseout;
  116.             curJavascript += "dmim('" + statMsg + "');";
  117.             if (restore) {
  118.                 eraseStatOnRestore =  true;
  119.             }
  120.         } else {
  121.             continue;
  122.         }
  123.         if (curBehavior.event == kEventMouseOver) {
  124.             javaOver += curJavascript;
  125.             if (gotStat) overStat = true;
  126.         }
  127.         if (curBehavior.event == kEventMouseOut) {
  128.             javaOut += curJavascript;
  129.             if (gotStat) outStat = true;
  130.         }
  131.         if (curBehavior.event == kEventOnClick) {
  132.             javaClick += curJavascript;
  133.             if (gotStat) hitStat = true;
  134.         }
  135.     }
  136.     if (eraseStatOnRestore) {
  137.         javaOut += "dmim('');" ;
  138.         outStat = true;
  139.     }
  140.     var ret = "return document.MM_returnValue";
  141.     if (overStat) javaOver += ret;
  142.     if (outStat) javaOut += ret;
  143.     if (hitStat) javaClick += ret;
  144.     return(gotJavascript);
  145. }
  146.  
  147. if (hasStatusMessages) {
  148.  
  149.     // The FrontPage webbot command "HTMLMarkup" specifies that code within it
  150.     // will not be changed when the file is opened or saved in FrontPage. 
  151.     // Write the JavaScript inside this webbot tag to avoid any loss of functionality.
  152.     write("<!--webbot bot=\"HTMLMarkup\" startspan -->\n");
  153.     WRITE_HTML("\n");
  154.     
  155.     // write out the status message display function.
  156.     WRITE_HTML("<script language=\"JavaScript\">\n");
  157.     WRITE_HTML("<!-- hide this script from non-javascript-enabled browsers\n");
  158.                                                                                    
  159.     // Begin Script. Hide Script from non-javascript-enabled browsers.
  160.     WRITE_HTML("// Function that displays status bar messageS\n")
  161.     WRITE_HTML("\n");
  162.     WRITE_HTML("var showMsg = navigator.userAgent != \"Mozilla/4.0 (compatible; MSIE 4.0; Mac_PowerPC)\";\n")
  163.     WRITE_HTML("function dmim(msgStr) {\n")
  164.     WRITE_HTML("  document.MM_returnValue = false;\n")
  165.     WRITE_HTML("  if (showMsg) {\n") 
  166.     WRITE_HTML("     window.status = msgStr;\n")
  167.     WRITE_HTML("     document.MM_returnValue = true;\n")
  168.     WRITE_HTML("  }\n")
  169.     WRITE_HTML("}\n")
  170.  
  171.     // Stop hiding script from non-javascript-enabled browsers. End script.
  172.     WRITE_HTML("// stop hiding -->\n");
  173.     WRITE_HTML("</script>\n");
  174.     
  175. // Close FrontPage webbot tag.
  176. write("<!--webbot bot=\"HTMLMarkup\" endspan -->\n");
  177.  
  178. }
  179.  
  180. // If a server-side image map is being export, write comment on replacing file path.
  181. if (exportDoc.serverMap) {
  182.     WRITE_HTML("<!--   ----------------------------------- NOTE ----------------------------------   --->\n");
  183.     WRITE_HTML("<!--   Replace the text in the following HREF tag with the path to your map file's    -->\n");
  184.     WRITE_HTML("<!--   location on the server. The \"", exportDoc.pathBase, ".map\" file generated by Fireworks needs to be  -->\n");
  185.     WRITE_HTML("<!--   placed in a directory with a CGI Application capable of interpreting the Image -->\n");
  186.     WRITE_HTML("<!--   Map information. If you are unsure about this, contact your web site           -->\n");
  187.     WRITE_HTML("<!--   administrator.                                                                 -->\n");
  188.     WRITE_HTML("\n");
  189.     
  190.     // Generate link to image map file.
  191.     WRITE_HTML("<a href=\"path_to_map_file/", exportDoc.pathBase, ".map\">\n");
  192. }
  193.  
  194. // Write image tag.
  195. WRITE_HTML("<img src=\"", exportDoc.filename,"\" "); 
  196.  
  197. // Determine width and height of image.
  198. WRITE_HTML("width=\"", exportDoc.width, "\" height=\"", exportDoc.height, "\"");
  199.  
  200. // If document has hotspots name the image map.
  201. if (hasImagemap) {
  202.     WRITE_HTML(" usemap=\"#", exportDoc.imagename, "\"")
  203. }
  204.  
  205. // Declare and write alt text.
  206. var altText = exportDoc.altText;
  207.  
  208. if (altText!="") {
  209.     WRITE_HTML(" alt=\"", altText, "\"");
  210. }
  211.  
  212. // If a server-side image map has been requested write ismap tag.
  213. if (exportDoc.serverMap) {
  214.     WRITE_HTML(" ismap");
  215. }
  216.  
  217. WRITE_HTML(" border=\"0\" >\n");
  218.  
  219. if (exportDoc.serverMap) {
  220.     WRITE_HTML("</a>\n");
  221. }
  222. WRITE_HTML("\n");
  223.  
  224.  // Write the image map inside of a HTMLMarkup webbot to allow
  225.  // rollovers and status bar messages attached to hotspots without
  226.  // having FrontPage write over them.
  227. if (hasImagemap) {
  228.     write("<!--webbot bot=\"HTMLMarkup\" startspan -->\n");
  229.             
  230.     // Write the image map.
  231.     WRITE_HTML("<map name=\"", exportDoc.imagename, "\">\n");
  232.  
  233.     var i = 0;
  234.     while (i < imagemap.numberOfURLs) {
  235.         var curImagemap = imagemap[i];
  236.         var behaviors = curImagemap.behaviors;
  237.         var javaOver = "";
  238.         var javaOut = "";
  239.         var javaClick = "";
  240.         var gotJavascript = ProcessBehavior(behaviors);
  241.  
  242.         // Write the area tag with shape definitions.
  243.         WRITE_HTML("<area shape=\"");
  244.         WRITE_HTML(curImagemap.shape); // Shapes are rect poly and circle
  245.         WRITE_HTML("\" coords=\"");
  246.         for (var j=0; j<curImagemap.numCoords; j++) {
  247.             if (j>0) WRITE_HTML(",");
  248.             // polygon has n coords.
  249.             // rect has 2 coords, topLeft, and botomRight.
  250.             // Circle has one coord; plus radius center.
  251.             WRITE_HTML(curImagemap.xCoord(j), ",", curImagemap.yCoord(j)); 
  252.         }
  253.         if (curImagemap.shape == "circle") {
  254.             // Write the radius for circle hotspots.
  255.             WRITE_HTML(", ", curImagemap.radius);
  256.         }
  257.         WRITE_HTML("\"");
  258.         var href = " href=\"#\"";
  259.         if (curImagemap.hasHref) {
  260.             href = " href=\"";
  261.             href += curImagemap.href;
  262.             href += "\"";
  263.             if (curImagemap.hasTargetText) {
  264.                 href += " target=\"";
  265.                 href += curImagemap.targetText;
  266.                 href += "\"";
  267.             }
  268.         }
  269.  
  270.         // Write status bar message commands.
  271.         if (javaOut != "") {
  272.             WRITE_HTML(" onMouseOut=\"", javaOut, "\" ");
  273.         }
  274.         if (javaOver != "") {
  275.             WRITE_HTML(" onMouseOver=\"", javaOver, "\" ");
  276.         }
  277.         if (javaClick != "") {
  278.             WRITE_HTML(" onClick=\"", javaClick, "\" ");
  279.         }
  280.         WRITE_HTML(href);
  281.  
  282.         // Write alt text for hotspot.
  283.         var altText = "";
  284.         if (curImagemap.hasAltText) {
  285.             altText = curImagemap.altText;
  286.         } else {
  287.             altText = exportDoc.altText;
  288.         }
  289.  
  290.         if (altText!="") {
  291.             WRITE_HTML(" title=\"", altText, "\"");
  292.             WRITE_HTML(" alt=\"", altText, "\"");
  293.         }
  294.  
  295.         WRITE_HTML(" >\n");
  296.         i++;
  297.     } 
  298.     
  299.     // Write the image's default URL here.
  300.     if (exportDoc.hasBackgroundLink && exportDoc.backgroundLink.href != "") {
  301.         var curImagemap = exportDoc.backgroundLink;
  302.         WRITE_HTML("<area shape=\"rectangle\" coords=\"0,0, ", exportDoc.width, ",", exportDoc.height, "\" ");
  303.         WRITE_HTML("href=\"", curImagemap.href, "\"");
  304.         if (curImagemap.hasTargetText) {
  305.             WRITE_HTML("\n  target=\"", curImagemap.targetText, "\"");
  306.         }
  307.         var altText = exportDoc.altText;
  308.         if (altText!="") {
  309.             WRITE_HTML(" title=\"", altText, "\"");
  310.             WRITE_HTML(" alt=\"", altText, "\"");
  311.         }
  312.         WRITE_HTML(">\n");
  313.     }    
  314.     WRITE_HTML("</map>\n")
  315.     WRITE_HTML("\n");
  316.     
  317.      // Close HTMLMarkup webbot.
  318.     write("<!--webbot bot=\"HTMLMarkup\" endspan -->\n");
  319.     
  320.     WRITE_HTML_COMMENT("   Image Map created with Macromedia Fireworks 2.0   ")
  321. }
  322.  
  323. WRITE_HTML("\n");
  324.  
  325. // End map copy/paste section.
  326. WRITE_HTML_COMMENT("----------------------------- STOP COPYING HERE ----------------------------")
  327.  
  328. WRITE_HTML("\n");
  329. WRITE_HTML("</body>\n")
  330.  
  331. WRITE_HTML("\n");
  332. WRITE_HTML("</html>\n")
  333.  
  334.